package com.duleme.entity;

import java.util.ArrayList;
import java.util.List;

public class ShoppingCart {
    private List<Book> books;
    private double totalPrice;
    private int count;
    private int userId;

    public ShoppingCart(){
        books = new ArrayList<>();
        totalPrice=0;
        count=0;
        userId=0;
    }

    public List<Book> getBooks() {
        return books;
    }

    public void setBooks(List<Book> books) {
        this.books = books;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double total) {
        this.totalPrice = total;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
    public void addBook(Book book){
        books.add(book);
        totalPrice+=book.getPrice();
        count+=1;
    }
    public void removeBook(int bookId){
        for (int i=0;i<count;i++){
            if(bookId==books.get(i).getBookId()){
                books.remove(i);
            }
        }
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }
}
